#pragma once
/*存档、读档功能
每次退出程序时，需要执行存档操作，把需要存的数据存储到文件中
因此，退出程序不应该直接叉掉而应该合规地退出防止数据丢失*/
#include"graph.h"
#include"login.h"
#include"SchoolBus.h"
#include<fstream>

/*需要存档的内容：
*1.登录：用户和管理员的全部数据
*2.地图：存储的所有点、线的信息
*/
class Save;

class RaySave {          //因为指针无法直接保存，所以应该做出一定修改
private:int ID;       //由于Dot是纯虚函数不能实例化，而点和ID一一对应，所以改用ID来存储射线连接的另外一个点
	double length;
public:
	RaySave() :ID(-1), length(-1) {};
	RaySave(int a, double b) :ID(a), length(b) {};
	friend class Save;
};

class StraightSave {    //因为指针无法直接保存，所以应该做出一定修改;由于Dot是纯虚函数不能实例化，而点和ID一一对应，所以改用ID来存储直线连接的两个点
private:int Edge1ID;      //线的端点1的ID
	int Edge2ID;       //线的端点2的ID
	string name;
public:
	StraightSave():Edge1ID(-1), Edge2ID(-1), name("Error") {};
	StraightSave(int a,int b,string d) :Edge1ID(a), Edge2ID(b), name(d) {};
    int GetEdge1ID() { return Edge1ID; }
    int GetEdge2ID() { return Edge2ID; }
    string Getname() { return name; }
	friend class Save;
	friend void Read(Save a);   //读取信息
};

//class CurveSave    //曲线功能扩展补充后在此添加内容

class Save {
private:
	vector<User>SaveUser;
	vector<Admin>SaveAdmin;
	vector<OrdinaryDot>SaveOrdinaryDot;         
	vector<Scenery>SaveScenery;
	vector<Crossroad>SaveCrossroad;
	vector<BusStation>SaveBusStation;
	vector<StraightSave>SaveStraight;
	//曲线扩展功能补充后在此添加内容
	int SaveDotID;
	vector<SchoolBus>SaveBusKu;
public:Save(vector<User> a, vector<Admin> b, vector<OrdinaryDot> c, vector<Scenery> d, vector<Crossroad> e, vector<StraightSave>f, vector<BusStation>g, vector<SchoolBus> h) :
	SaveUser(a), SaveAdmin(b), SaveOrdinaryDot(c), SaveScenery(d), SaveCrossroad(e), SaveStraight(f), SaveBusStation(g), SaveBusKu(h) {
	this->SaveDotID = DotID;
};
	  Save() { 
		  vector<User> a;
		  vector<Admin> b;
		  vector<OrdinaryDot> c;
		  vector<Scenery> d;
		  vector<Crossroad> e;
		  vector<StraightSave>f;
		  vector<BusStation>g;
		  vector<SchoolBus> h;
		  SaveUser = a; SaveAdmin = b; SaveOrdinaryDot = c; SaveScenery = d; SaveCrossroad = e; SaveStraight = f; SaveBusStation = g; SaveBusKu=h;
		  this->SaveDotID = DotID;
	  };
	 void Saving(vector<Person*>Ku, vector<Dot*>DotKu, vector<Line*>LineKu);      //存储状态
	 friend void Read(Save a);   //读取信息

     friend void SaveProgram(string outfile1, string outfile2, string outfile3, string outfile4, string outfile5, string outfile6, string outfile7);
friend void ReadProgram(string infile1, string infile2, string infile3, string infile4, string infile5, string infile6, string infile7);
};


